package Javatest;

public class test_5_31 {



//    public static void main(String[] args) {
//        String s = "abcdef";
//        char arr[] = s.toCharArray();
//        for(int i = 0;i<arr.length;i++)
//            System.out.print(arr[i]);
//    }

    public static class Test1 {

        //创建属性
        public String name;
        public int age;
        public double weight;

        //构造方法
        public Test1(String name, int age, double weight)
        {
            this.name = name;
            this.age = age;
            this.weight = weight;
        }

        //setter &getter
        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        public double getWeight() {
            return weight;
        }

        public void setWeight(double weight) {
            this.weight = weight;
        }

//	5.1.1定义一个方法sayHello()，可以向对方发出问候语“hello,my name is XXX”
//	5.1.2有三个属性：名字、年龄、体重
//	5.1.3通过构造方法，分别给三个属性赋值

        //创建方法
        public void sayHello()
        {
            System.out.println("hello,my name is "+name);
        }

        public static void main(String[] args) {
            // TODO 自动生成的方法存根
            Test1 name = new Test1("zhangsan", 18, 45);
            System.out.println(name.getName());
            name.sayHello();

        }





    }



}
